/*
 * @Author: 李石
 * @Date: 2024-05-18 10:34:16
 * @LastEditors: lishi
 * @LastEditTime: 2024-05-22 19:38:26
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef _HTTP_DATA_HPP_
#define _HTTP_DATA_HPP_

#include <iostream>
#include <string>
#include <memory>
#include "mongoose.h"

class HttpData{
public:
    using Ptr = std::shared_ptr<HttpData>;
    static Ptr CreateShared(struct mg_connection *c,struct mg_http_message *hm);
    HttpData(struct mg_connection *c,struct mg_http_message *hm);
    ~HttpData() = default;
    bool is_valid() const { return m_vaild; }
    size_t content_len() const { return http_content_len; }
    int remote_port() const { return http_remote_port; }
    const std::string& err_msg() const { return http_err_msg; }
    const std::string& uri() const { return http_uri; }
    const std::string& method() const { return http_method; }
    const std::string& remote_ip() const { return http_remote_ip; }
    const std::string& content_type() const { return http_content_type; }
    const std::string& body() const { return http_body; }
    const std::string to_string(bool pretty = true) const ;

private:
    bool        m_vaild;
    size_t      http_content_len = 0;
    int         http_remote_port = 0;
    std::string http_err_msg = "";
    std::string http_uri = "";
    std::string http_method = "";
    std::string http_remote_ip = "";
    std::string http_content_type = "";
    std::string http_body = "";
};

#endif // _HTTP_DATA_HPP_